﻿@model Susha.Areas.Admin.Models.Pages.MenuPageAdmin

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section scripts{
    @Scripts.Render("/Scripts/common/admin-menu.js")
    @Scripts.Render("/Scripts/common/admin.js")
    @Scripts.Render("/Scripts/common/user.js")
    @Scripts.Render("/Scripts/jquery-1.8.2.min.js")
}

<h1>Меню администратора</h1>

<div id="asdf">asdf <br/></div>

<script>
    startingFunction();
</script>

@foreach (Susha.Models.Category cat in Model.Categories)
{
    <div class="category" id="category-@cat.Id">
        <div class="category-name">
            <input type="text" id="category_name_@cat.Id" onblur="ChangeCategoryName(@cat.Id)" value="@cat.Name" />
            <button class="" onclick="DeleteCategory(@cat.Id, '@cat.Name')">Удалить секцию со всеми суши</button>
        </div>
        @foreach (Susha.Models.Sushi sushi in cat.Sushi)
        {
            <div class="sushi-admin-cover" id="sushi-admin-cover-@sushi.Id">
                <div class="sushi-admin" id="sushi-@sushi.Id" draggable="true" style="background-image:url('@Url.Content("~/Content/i/")@sushi.SmallPhoto')">
                    <div class="sushi-photo-admin" onmousedown="handlerMouseDown(this, event)"></div>
                    <div class="sushi-info-admin">
                        <span class="sushi-name-label-admin">Название: </span> <input type="text" class="sushi-name-admin" id="sushi-name-@sushi.Id" onblur="ChangeSushiName(@sushi.Id)" value="@sushi.Name" />
                        <span class="sushi-price-label-admin">Цена: </span> <input type="text" class="sushi-price-admin" id="sushi-price-@sushi.Id" onblur="ChangePrice(@sushi.Id)" value="@sushi.Price" />
                        @using(Html.BeginForm("UploadImage", "Menu", FormMethod.Post, new { enctype = "multipart/form-data" }))
                        {
                            @Html.TextBox("SushiId", Model.TypicalSushi.SushiId, new { Value = sushi.Id, hidden = "hidden" })
                            @Html.TextBox("SushiPhoto", Model.TypicalSushi.SushiPhoto, new { type = "file", size="5", accept="image/jpeg,image/png,image/gif" })
                            <button type="submit">Загрузить фотографию</button>
                        }
                        <button onclick="DeleteSushi(@sushi.Id, '@sushi.Name')">Удалить @sushi.Name</button>
                    </div>
                </div>
            </div>
            
            <script>
                addSushiToArray(@sushi.Id);
            </script>
        }
        <!-- New sushi -->
            <div class="sushi-admin-cover">
                <div class="sushi-admin" id="new-sushi-@cat.Id">
                    <div class="sushi-info-admin">
                        <span class="sushi-name-label-admin">Название: </span> <input class="sushi-name-admin" type="text" id="new-sushi-name-@cat.Id" value="" placeholder="Name" />
                        <span class="sushi-price-label-admin">Цена: </span> <input class="sushi-price-admin" type="text" id="new-sushi-price-@cat.Id" value="" placeholder="Price" />
                        <button type="button" onclick="CreateSushi(@cat.Id)">Создать суши</button>
                    </div>
                </div>
            </div>
    </div>
    <div class="end"></div>
}
<div class="category" id="new-category">
    <div class="category-name">
        <input type="text" id="new-category-name" onblur="CreateCategory()" value="" placeholder="Новая категория" />
    </div>
</div>